/**
 * 
 */
package sparql.obac.ecsu.isical.ac.in;


import org.apache.log4j.Logger;

import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryFactory;

import com.hp.hpl.jena.sparql.algebra.Algebra;
import com.hp.hpl.jena.sparql.algebra.Op;
import com.hp.hpl.jena.sparql.core.DatasetDescription;
import com.hp.hpl.jena.sparql.syntax.Element;



/**
 * @author subhasis
 *
 */
public class sparqlQueryHandling {
	private String newQuery;
	private DatasetDescription dataSetD;
	static Logger log = Logger.getLogger(sparqlQueryHandling.class.getName());

	/**
	 * @param newQuery
	 */
	public sparqlQueryHandling(String newQuery) {
		this.newQuery = newQuery;
		Query qt = this.splitQuery(newQuery);
		
	}
	
	public Query splitQuery(String tQuery)
	{
		Query query = QueryFactory.create(newQuery);
		DatasetDescription tdataSetD = query.getDatasetDescription();
		this.setDataSetD(tdataSetD);
		Element tQPattern = query.getQueryPattern();
		Op op = Algebra.compile(query);
		System.out.println("Operation Type : \t"+op.getName());
		System.out.println("Tuple to request :\t"+query.getResultVars().toString());
		System.out.println("Data URI:  \t"+query.getGraphURIs().toString());
		
		
		return query;
	}

	/**
	 * @return the dataSetD
	 */
	public DatasetDescription getDataSetD() {
		return dataSetD;
	}

	/**
	 * @param dataSetD the dataSetD to set
	 */
	public void setDataSetD(DatasetDescription dataSetD) {
		this.dataSetD = dataSetD;
	}

}
